﻿using System.Threading;
using mshtml;
using SHDocVw;

namespace MQuery
{
    class MQueryUnitTest
    {
        static InternetExplorer ie;
        public static HTMLDocumentClass Load(string url)
        {
            ie = new InternetExplorerClass();
            ManualResetEvent waitObject = new ManualResetEvent(false);
            ie.DocumentComplete += (object x, ref object y) => waitObject.Set();
            object o = new object();
            ie.Navigate(url, ref o, ref o, ref o, ref o);
            waitObject.WaitOne();
            HTMLDocumentClass doc = (HTMLDocumentClass)ie.Document;
            return doc;
        }

        public static void Quit()
        {
            ie.Quit();
            ie = null;
        }
    }
}
